package com.star.wellconnect.signuplogin;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.star.wellconnect.sqlite.AppPreferences;

public class SLFragmentPagerAdapter extends FragmentPagerAdapter{
	private String[] pages;
	private Context mContext;
	
	public SLFragmentPagerAdapter(FragmentManager fm, String[] pages, Context context) {
		super(fm);
		this.pages = pages;
		this.mContext = context;
	}

	@Override
	public Fragment getItem(int position) {
		switch(position){
	    case 1:
	    	return new SignupFragment(); 	
	    default:
	    	if(AppPreferences.isLoggedIn(mContext))
	    		return new LoggedInFragment();
	    	else
	    		return new LoginFragment();
	    }
	}

	@Override
	public int getCount() {
		return pages.length;
	}
	
	@Override
	public CharSequence getPageTitle(int position){
		return (CharSequence) pages[position];
	}
}
